package com.ft.mq;

import java.util.Date;
import java.util.Random;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;

public class MQSender {
	@Autowired
	private RabbitTemplate rabbitTemplate;

	@Scheduled(fixedDelay = 1000L)
	public void send() {
		Random random=new Random();// 定义随机类
		int result=random.nextInt(100);
		System.out.println("Sender-----"+new Date() + " 发送消息: hello-" + result);
		this.rabbitTemplate.convertAndSend("foo", "hello-" + result);
	}
}
